home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 19
/
CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso
/
CUCD
/
Readers
/
ExtremeAmos
/
Text
/
R_DRAW_Buttons.ASC
< prev
next >
Wrap
Text File
|
1995-12-30
|
5KB
|
94 lines
ü
DRAW button tutorial
~~~~~~~~~~~~~~~~~~~~
ù
You would not believe how usefull a DRAW button routine can be if
you have never used one before. In the old times, you had to use lot's
of different sprites, or have a next screen with the depression of a
key you can press, but a DRAW command totally eliminates this, and is
a whole lot faster, and less memory consuming.
ý
Try to imagine a screen such as directory opus. The different
buttons on that are drawn using a DRAW button routine, otherwise there
would be loads of sprites in memory, taking up even more sprites that
what are already used. But, with 4 DRAW commands in AMOS, I can change
ANY of the buttons, no matter what the size, to any colour or shape.
ø
How do you do this, I hear you ask. One way is to draw solid line
boxes on a screen using Dpaint, and add all the text etc. that you
want to have printed, so that you can make a perfect size estimation
of where you want all of the different buttons to go. The next step is
to jot down all the top-left and bottom-right hand coordinates on a
pad, so that you can enter them into the AMOS program a bit later. You
ÿ
ø
can then erase all of the box lines, and just Spack the background
that is left into memory, which should make the size of the compressed
picture a little smaller.
û
As you see this issue running, the borders surrounding each of the
icons are all done using the same DRAW routine, as is the windows and
borders used. This saves me a lot of time and memory when compiled. I
can also change the size and shape of any of the borders without
having to worry too much about the memory being used, if I had used a
bob or icon.
ý
All the coordinates are placed into 4 arrays. In this case, we
will use A, B, C, and D. As a default, I normally set the number of
elements to 200 (to allow 200 buttons to be stored in mem), but when a
program is finished, I cut it down to the correct size, so that I can
grab those extra few bytes back. A and B represent the top left-hand
corner of the box, whereas C and D represent the bottom right. These
are the pixels on the screen to be used by the DRAW routine, and can
also be used for other tings, such as clearing the appropriate box off
the screen, or to place a ZONE around it for detection via the mouse,
ÿ
ý
plus loads more other things.
ù
The DRAW routine is extremely simple. You could simple use a Box
A(no.),B(no.) To C(no.),D(no.) command, which would simply draw a solid
lined box around the area, in one colour. In order to get the
different height effect, we use 2 colours, normally white and black,
which when inversed around, appear to be either indented or standing
out from the paper. It is always a good idea to have a second colour
black in the palette, as sprites and blocks are always affected by the
transparancy of colour 0. The first 2 DRAW statements are called to
the top left-hand corner, to the bottom left hand cornar, joining at
the bottom right corner, with the other 2 changing colour and although
joining at the same ends, takes route via the top right hand corner
instead. Simple. Because you can alter the colours of each direction,
you re-create the effect of having "Pressed" on the button.
ø
An example here would be a waste of time, so in the SOURCE section
on disk 2, there is a small program labelled "AK_Buttons.AMOS", which
I tore out from one of my module players, which demonstrates how
simple and effective the routines can be. The program it was taken
ÿ
ø
from is MMPlay GUI, a module player which I am still working on, which
plays any Sound/Pro/Noisetracker modules, along with any AMOS Tracker
or music banks, and also MED modules (MMD0 and MMD1). Features
supported include a jukebox player (plays lists constantly) as well as
modules in random order. A demo version is available from me now, and
will be on next issue's coverdisk. Send SAE and disk for your demo now
!! You know where the address is.
û
Well, it is time for me to wet the bed, so to speak, so until we
happen to meet at some point in our lives, it's goodnight to you from
me and Millie. Chow, dudes and dudettes.
ú
[Andrew "Mushroom" Kellett]
÷
EOF